# Maintainer: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=subprocess32
pkgbase=mingw-w64-python-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-python2-${_realname}"
_gitname=python-${_realname}
pkgver=3.5.3
pkgrel=1
pkgdesc='Backport of the Python 3 subprocess module (mingw-w64)'
url='https://github.com/google/python-subprocess32'
arch=('any')
license=('custom')
depends=("${MINGW_PACKAGE_PREFIX}-python2")
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/google/python-subprocess32/archive/${pkgver}.tar.gz")
sha512sums=('f8b3a0f28e30b804a5d426fd7d3139f9e9492023a07e4242689ded73dff29ea50487d61f5bcbdd1dd4387c22cf366681f830700afbe4fdae1a4c14a669fa2d3d')

build() {
  cd ${_gitname}-${pkgver}
  ${MINGW_PREFIX}/bin/python2 setup.py build
}

check() {
  cd ${_gitname}-${pkgver}
  local PYTHONVERSION="$(${MINGW_PREFIX}/bin/python2 -c 'import sys; print("{}.{}".format(sys.version_info.major, sys.version_info.minor))')"
  PYTHONPATH="build/lib.linux-${CARCH}-${PYTHONVERSION}" \
    ${MINGW_PREFIX}/bin/python2 test_subprocess32.py
}

package() {
  cd ${_gitname}-${pkgver}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install -O1 --root="${pkgdir}" --prefix=${MINGW_PREFIX} --skip-build
  install -Dm 644 LICENSE -t "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}"
  install -Dm 644 README.md ChangeLog -t "${pkgdir}${MINGW_PREFIX}/share/doc/python2-${_realname}"
}

# vim: ts=2 sw=2 et:
